HTML - tags - audio tag

Revision:


Content

"audio" tag : embeds sound content in a documen syntax some examples


"audio" tag : embeds sound content in a document

top

The <audio> tag is used to embed sound content in a document, such as music or other audio streams. The <audio> tag contains one or more <source> tags with different audio sources. The browser will choose the first source it supports. The text between the <audio> and </audio> tags will only be displayed in browsers that do not support the <audio> element. There are three supported audio formats in HTML: MP3, WAV, and OGG.

Attributes: the <audio> element supports the global attributes and events attributes. The tag also supports the following additional attributes:

autoplay : value: autoplay;

specifies that the audio will start playing as soon as it is ready.

controls : value: controls;

specifies that audio controls should be displayed (such as a play/pause button etc).

loop : value: loop;

specifies that the audio will start over again, every time it is finished.

muted : value: muted;

specifies that the audio output should be muted.

preload : value: auto, metadata, none;

specifies if and how the author thinks the audio should be loaded when the page loads.

src : value: URL;

specifies the URL of the audio file.


Syntax

top

<audio> . . . </audio>


some examples

top

example

Code:

                    <audio style="margin-left:6vw;" controls>
                        <source src="../../pics/horse.wav" type="audio/wav">
                        Your browser does not support the audio element.
                    </audio>
                

example

Code:

                    <audio style="margin-left:6vw;" src="../../pics/horse.wav" controls loop>
                        Your browser does not support the audio element.
                    </audio>